mw.loader.store: temporarily allow users to opt-in via cookie
authorOri Livneh <ori@wikimedia.org>
Wed, 30 Oct 2013 22:23:48 +0000 (15:23 -0700)
committerOri.livneh <ori@wikimedia.org>
Wed, 30 Oct 2013 22:53:34 +0000 (22:53 +0000)
To facilitate mw.loader.store testing on production wikis, it would be good to
allow developers and JavaScript-savvy users to opt-in for mw.loader.store
testing by manually setting a cookie in their browser. With this patch in
place, this would be possible to do by executing the following statement in a
debug console:

    $.cookie( 'ResourceLoaderStorageEnabled', 1, { expires: 7, path: '/' } );

This will be removed from mediawiki.js (long) before the 1.23 release.

Bug: 56397
Change-Id: I51cfd563734a3aeed3667fbb19bf3be40fabbb6b

resources/mediawiki/mediawiki.js

index f1b3082..9267a49 100644 (file)
@@ -1799,14 +1799,18 @@ var mw = ( function ( $, undefined ) {
                                         * code for a full account of why we need a try / catch: <http://git.io/4NEwKg>.
                                         */
                                        init: function () {
-                                               var raw, data;
+                                               var raw, data, optedIn;
 
                                                if ( mw.loader.store.enabled !== null ) {
                                                        // #init already ran.
                                                        return;
                                                }
 
-                                               if ( !mw.config.get( 'wgResourceLoaderStorageEnabled' ) || mw.config.get( 'debug' ) ) {
+                                               // Temporarily allow users to opt-in during mw.loader.store test phase by
+                                               // manually setting a cookie (bug 56397).
+                                               optedIn = /ResourceLoaderStorageEnabled=1/.test( document.cookie );
+
+                                               if ( !( mw.config.get( 'wgResourceLoaderStorageEnabled' ) || optedIn ) || mw.config.get( 'debug' ) ) {
                                                        // Disabled by configuration, or because debug mode is set.
                                                        mw.loader.store.enabled = false;
                                                        return;